#ifndef _THREAD_POOL_H_
#define _THREAD_POOL_H_

#include <deque>
#include <mutex>
#include <thread>
#include <map>
#include <vector>
#include <functional>

using namespace std;

namespace loong
{
class ThreadPool;
class WorkThread
{
public:
    WorkThread(ThreadPool *pool);
    ~WorkThread();

    void setInitCallback(function<void ()> initCallback);
    void setWorkCallback(function<void ()> workCallback);

    void run();
    
private:
    ThreadPool *m_pool;
private:
    function<void ()> m_initCallback;
    function<void ()> m_workCallback; 
};


class ThreadPool
{
public:
    ThreadPool(uint32_t threadNum);
    ~ThreadPool();
public:
    void setThreadInitCallback(function<void ()> threadInitCallback);
    void setThreadWrokCallback(function<void ()> threadWorkCallback);
    
    void start();
private:
    int m_threadNum;
    std::vector<WorkThread*> m_works;
    std::vector<std::thread*> m_threads;
    
    function<void ()> m_threadInitCallback;
    function<void ()> m_threadWorkCallback;
};
}

#endif // _THREAD_POOL_H_
